package cn.scm.server.multistage.controller;

import cn.scm.server.multistage.base.PageParam;
import cn.scm.server.multistage.base.ResultDTO;
import cn.scm.server.multistage.dto.BizOpenOrderDTO;
import cn.scm.server.multistage.param.BizOpenOrderParam;
import cn.scm.server.multistage.service.BizOpenOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 开单记录表(BizOpenOrder)表控制层
 *
 * @author makejava
 * @since 2020-09-23 20:53:05
 */
@RestController
@RequestMapping("bizOpenOrder")
@Api(tags = "开单管理")
public class BizOpenOrderController {
    /**
     * 服务对象
     */
    @Resource
    private BizOpenOrderService bizOpenOrderService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    /*@GetMapping("selectOne")
    public BizOpenOrder selectOne(String id) {
        return this.bizOpenOrderService.queryById(id);
    }*/

    @PostMapping("save")
    @ApiOperation("保存开单")
    public ResultDTO save(@ApiParam(value = "开单参数",required = true) @RequestBody BizOpenOrderParam param) {
        //TODO
        return ResultDTO.success();
    }

    @PostMapping("list")
    @ApiOperation("开单审批列表查询")
    public ResultDTO<List<BizOpenOrderDTO>> list(@ApiParam(value = "开单参数",required = true) @RequestBody BizOpenOrderParam param,
                                                 @ApiParam(value = "分页参数",required = true) @RequestBody PageParam pageParam) {
        //TODO 查询所有的开单记录
        ArrayList<BizOpenOrderDTO> bizOpenOrderDTOS = new ArrayList<>();
        return ResultDTO.success(bizOpenOrderDTOS);
    }

    @PostMapping("update")
    @ApiOperation("修改状态")
    public ResultDTO update(@ApiParam(value = "开单记录ID",required = true) @RequestParam String id,
                            @ApiParam(value = "悟新状态 1开单成功，2拆分成功，3转让中，4转让失败，5已转出",required = true) Integer status,
                            @ApiParam(value = "修改类型 0 修改悟性状态，1 修改审批状态",required = true) @RequestParam String updateType) {
        //TODO
        return ResultDTO.success();
    }

    @PostMapping("confirmList")
    @ApiOperation("确认开单列表")
    public ResultDTO<List<BizOpenOrderDTO>> confirmList(@ApiParam(value = "开单参数",required = true) @RequestBody BizOpenOrderParam param,
                                                 @ApiParam(value = "分页参数",required = true) @RequestBody PageParam pageParam) {
        //TODO 查询已审批的开单记录
        ArrayList<BizOpenOrderDTO> bizOpenOrderDTOS = new ArrayList<>();
        return ResultDTO.success(bizOpenOrderDTOS);
    }

}